﻿using PetaPoco;
using PmSoft;
using PmSoft.Caching;
using System.ComponentModel;
using static Modules.Device.CheckInDeviceConstants;

namespace Modules.Device.Entitys
{
    /// <summary>
    /// 项目考勤设备管理
    ///</summary>
    [TableName("checkin_device")]
    [Description("考勤设备信息")]
    [PrimaryKey("id", AutoIncrement = true)]
    [CacheSetting(true, Name = "CheckinDevice", PropertyNamesOfArea = "ProjectId")]
    [Serializable]
    public class CheckinDevice : IEntity
    {
        /// <summary>
        /// 主键
        ///</summary>
        [Column("id")]
        public int Id { get; set; }

        /// <summary>
        /// 项目id
        ///</summary>
        [Column("project_id")]
        public int ProjectId { get; set; }

        /// <summary>
        /// 所属企业Id
        ///</summary>
        [Column("corp_id")]
        public int CorpId { get; set; }

        /// <summary>
        /// 设备类型(海清......)
        ///</summary>
        [Column("type")]
        public 考勤设备设备厂家 Type { get; set; }

        /// <summary>
        /// 设备名称
        ///</summary>
        [Column("name")]
        public string Name { get; set; }

        /// <summary>
        /// 设备序列号(设备编号)
        ///</summary>
        [Column("code")]
        public string Code { get; set; }

        /// <summary>
        /// 有效起始日期
        ///</summary>
        [Column("start_date")]
        public DateTime StartDate { get; set; }

        /// <summary>
        /// 有效截至日期
        ///</summary>
        [Column("end_date")]
        public DateTime EndDate { get; set; }

        /// <summary>
        /// 进出(1 进  2 出)
        ///</summary>
        [Column("in_out")]
        public 进出 InOut { get; set; }

        /// <summary>
        /// 设备型号
        ///</summary>
        [Column("model")]
        public string? Model { get; set; }

        /// <summary>
        /// 设备版本
        ///</summary>
        [Column("version")]
        public string? Version { get; set; }

        /// <summary>
        /// 备注
        ///</summary>
        [Column("remark")]
        public string? Remark { get; set; }

        /// <summary>
        /// 是否禁用
        ///</summary>
        [Column("is_disable")]
        public bool IsDisable { get; set; }

        /// <summary>
        /// 创建时间
        ///</summary>
        [Column("create_time")]
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 是否在线
        ///</summary>
        [Column("is_online")]
        public bool IsOnline { get; set; }

        /// <summary>
        /// 设备在线服务器
        /// </summary>
        [Column("online_server")]
        public string OnlineServer { get; set; }

        /// <summary>
        /// ip地址
        ///</summary>
        [Column("ip_address")]
        public string IpAddress { get; set; }

        /// <summary>
        /// 最后同步时间
        /// </summary>
        [Column("last_sync_time")]
        public DateTime LastSyncTime { get; set; }

        /// <summary>
        /// 平台 ProductKey 标识，用于绑定对应账号 (用户名)
        /// </summary>
        [Column("user")]
        public string? User { get; set; }

        /// <summary>
        /// 平台ProductSecret标识，用于绑定对应账号 （密码）
        /// </summary>
        [Column("pwd")]
        public string? Pwd { get; set; }

        #region IEntity 成员

        [Ignore]
        object IEntity.EntityId { get { return Id; } }

        #endregion IEntity 成员
    }
}